#include "xsheet.h"
#include "smil/par.h"
#include <iostream>
#include "xsheetwidget.h"
#include "smil/enums.h"

ExposureSheet::ExposureSheet()
{
    set_type_hint(Gdk::WINDOW_TYPE_HINT_UTILITY);
    set_size_request(200,500);
    set_title("Exposure Sheet");
    add(vsplit);
    el_hbox.pack_start(upbutton,false,false);
    el_hbox.pack_start(title,true,true);
    upbutton.set_label(Gtk::Stock::GO_UP.id);
    upbutton.set_use_stock(true);
    el_vbox.pack_start(el_hbox,false,true);
    el_vbox.pack_start(my_view);
    el_vbox.pack_start(buttonbar,false,false);
    Gtk::ToolButton* pButton;
    Gtk::Widget* pWidget;
    pButton = Gtk::manage(new Gtk::ToolButton());
    pWidget = Gtk::manage(new Gtk::Image(Gtk::StockID(Gtk::Stock::NEW), Gtk::ICON_SIZE_BUTTON));
    pButton->set_icon_widget(*pWidget);
    buttonbar.append(*pButton);
    pButton = Gtk::manage(new Gtk::ToolButton());
    pWidget = Gtk::manage(new Gtk::Image(Gtk::StockID(Gtk::Stock::ADD), Gtk::ICON_SIZE_BUTTON));
    pButton->set_icon_widget(*pWidget);
    buttonbar.append(*pButton);
    pButton = Gtk::manage(new Gtk::ToolButton());
    pWidget = Gtk::manage(new Gtk::Image(Gtk::StockID(Gtk::Stock::REMOVE), Gtk::ICON_SIZE_BUTTON));
    pButton->set_icon_widget(*pWidget);
    buttonbar.append(*pButton);
    pButton = Gtk::manage(new Gtk::ToolButton());
    pWidget = Gtk::manage(new Gtk::Image(Gtk::StockID(Gtk::Stock::GO_FORWARD), Gtk::ICON_SIZE_BUTTON));
    pButton->set_icon_widget(*pWidget);
    buttonbar.append(*pButton);
    pButton = Gtk::manage(new Gtk::ToolButton());
    pWidget = Gtk::manage(new Gtk::Image(Gtk::StockID(Gtk::Stock::GO_BACK), Gtk::ICON_SIZE_BUTTON));
    pButton->set_icon_widget(*pWidget);
    buttonbar.append(*pButton);
    title.set_text("#par8123");
    title.set_editable(false);
    vsplit.add1(el_vbox);
    vsplit.pack2(propview,false, true);
    propview.set_label("Properties");
    my_view.add(my_sheet);
    my_view.set_border_width(20);
    show_all_children();
}

void ExposureSheet::test()
{
    testseq = Glib::RefPtr<smil::BasicTiming> (new smil::seq);
    testseq->dur.value = 1000;
    testseq->dur.is_set = true;
    smil::duration active = testseq->get_active_duration();
    std::cout << "Value: " << active.value << std::endl
    << "State: " << active.state << std::endl;
    my_sheet.load(testseq);
}

ExposureSheet::~ExposureSheet()
{
}

bool ExposureSheet::on_delete_event(GdkEventAny * event)
{
    hide();
    return true; // handled
}
